package com.example.schooljava.service.impl;

import com.example.schooljava.pojo.entity.Exam;
import com.example.schooljava.mapper.ExamMapper;
import com.example.schooljava.service.ExamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.schooljava.util.Result;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LDH
 * @since 2022/08/11
 */
@Service
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService {

    @Override
    public Result inPutScore(Exam exam) {
        save(exam);
        return new Result<>().OK(true,"成绩录入成功！");
    }

    @Override
    public Result inPutList(Map<String, List<Exam>> exams) {
        //获取用户集合
        List<Exam> list = exams.get("exams");
        //遍历集合依次根据id更新用户信息
        list.forEach(this::save);
        return new Result<>().OK(true,"批量录入成绩成功！");
    }
}
